package com.yuezhi.consumer.config;

import com.yuezhi.consumer.constant.QueueConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DlxConfig {
    @Bean
    Queue dlxReceiveQueue() {
        return new Queue(QueueConstant.DLX_RECEIVE_QUEUE, true, false, false);
    }

    @Bean
    DirectExchange dlxReceiveExchange() {
        return new DirectExchange(QueueConstant.DLX_RECEIVE_EXCHANGE, true, false);
    }

    @Bean
    Binding dlxReceiveBinding() {
        return BindingBuilder.bind(dlxReceiveQueue()).to(dlxReceiveExchange()).with(QueueConstant.DLX_ROUTE_KEY);
    }
}
